/**
 * Created by forcht on 2018/5/16.
 */
public class Solution {
    public double findMedianSortedArrays(int A[], int B[]) {
        int[] d=new int[A.length+B.length];
        int i=0;
        int j=0;
        int k=0;
        while (i<A.length&&j<B.length){
            if (A[i] <= B[j]) {
                d[k++]=A[i++];
            }else {
                d[k++]=B[j++];
            }
        }
        while (i<A.length){
            d[k++]=A[i++];
        }
        while (j<B.length){
            d[k++]=B[j++];
        }
        if(k%2==1)return d[k/2];
        else return (d[k/2]+d[k/2-1])/2.0;
    }
}
